<?php
/**
 * @fileoverview
 * @data         碎碎念，好友动态
 */
class ml_biz_feed_user extends ml_biz_feed_abstract{
    private $res_rid = array();
    /**
     * @fileoverview    拆feed数据，获取扩展数据
     * @uid            visitor['uid']
     */
    public function output($data,$uid){        
        $oContent = new ml_model_dbContent();
        foreach ($data as $v_rid) {
            if($v_rid['type']==ML_FEED_TYPE_ATTITUDE||$v_rid['type']==ML_FEED_TYPE_REPOST_COLLECTION || $v_rid['type'] == ML_FEED_TYPE_PUB_DOTEY){
                $this->res_rid[] = $v_rid['content_rid'];
            }
            //增加喜欢的中间人
            if(!empty($v_rid['feed_info']['middle_uid'])){
                $uids[]=$v_rid['feed_info']['middle_uid'];
            }
        }
        
        $this->nicks=ml_tool_nick::uids2nicks($uids);
           foreach($this->nicks as $key=>$val){
               $user[$key]=$this->_format_user($key);
           }
       
        $res = $oContent->get_content_by_rids($this->res_rid);
        
        
        foreach ($data as &$fen) {
            $fen['show_share'] = true;
            $fen['show_com'] = true;
            $fen['show_com_cnt'] = true;
            $fen['is_feed'] =true;
            $fen['show_del'] = $uid==$fen['uid']?true:false;
            $fen['feed_rid'] = $fen['rid'];
            $fen['content_NM'] = $fen['content'];
            $fen['content']  = $this->format_public($fen['content']);
            switch ($fen['type']) {

                case ML_FEED_TYPE_ATTITUDE:
                    $fen['rid'] = $fen['content_rid'];
                    $fen['show_type'] = 'quote';
                    $fen['res'] = $res[$fen['rid']];
                    $fen['content'] = $this->formate_att_content($fen['feed_info']['attitude']);
                    if(!empty($fen['feed_info']['middle_uid'])){
                        
                        $fen['content'].=$this->format_like_user($fen['feed_info']['middle_uid'],$user[$fen['feed_info']['middle_uid']]['nick']);
                        $fen['content'].= $this->formate_att_content($fen['feed_info']['attitude']);
                    }
                    
                    break;
                case ML_FEED_TYPE_REPOST_COLLECTION://如果又加了专辑这需要改下
                    $fen['rid'] = $fen['content_rid'];
                    $fen['show_type'] = 'quote';
                    $fen['res'] = $res[$fen['rid']];
                    $fen['content'] = $this->format_collect_content($fen);
                    break;
                case ML_FEED_TYPE_PUB_SHORT:
                    $fen['show_type'] = 'txt';
                    break;
                case ML_FEED_TYPE_MOD_DEC:
                    $fen['show_type'] = 'txt';
                    $fen['content'] = $this->formate_dec_content($fen['content']);
                    break;
                case ML_FEED_TYPE_MOD_TAG:
                    $fen['show_type'] = 'txt';
                    $fen['content'] = $this->formate_tag_content($fen['content']);
                    break;
                case ML_FEED_TYPE_PUB_PIC:
                    $fen['show_type'] = 'pic';
                    $fen['rid'] = $fen['content_rid'];
                    $fen['res'] =
                    array(
                         'gd_price'=>$fen['feed_info']['gd_price'],
                         'gd_title'=>$fen['feed_info']['gd_title'],
                         'type_xrank'=>ML_CONTENT_XRANK_IMG,
                         'pic_id'=>$fen['pic_id'],
                         'rid' => $fen['content_rid'],
                         'uid'=> $fen['uid']
                    );
                    break;
                case ML_FEED_TYPE_PUB_DOTEY:
                    $fen['show_type'] = 'pic';
                    $fen['rid'] = $fen['content_rid'];
                    $fen['res'] = $res[$fen['rid']];
                    
                    $fen['res']['gd_price'] =$fen['feed_info']['gd_price'];
                    $fen['res']['gd_title']=$fen['feed_info']['gd_title'];
                    $fen['res']['type_xrank']=ML_CONTENT_XRANK_GOODS;
                    $fen['res']['pic_id'] =$fen['pic_id'];
                    break;

            }

        }

        return $this->parse($data);
    }
    
}
?>